<%@page import="serializare.SerializationToXml"%>
<%@page import="java.util.List"%>
<%@page import="java.util.ArrayList"%>
<%@page import="java.util.Enumeration"%>
<%@page import="core.controller.ServletParameters"%>
<%@page import="bean.Person"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
    <% 
    List<Person> persons = null;
    if ((ServletParameters.getProjectPath() + "serialize.xml") != null){
        persons = SerializationToXml.deserializeXMLToObject();
    }
    else{
       persons = new ArrayList<Person>(); 
       }
    int idPerson = 1;
    if (persons != null){
       for (Person pers : persons)
              idPerson = pers.getId()+1; 
    }else{
            idPerson=1;
     }
    %>
        <B>Add personal data</b>
        <form action="ActionController" method="POST" name="description" >
            <table>
                <tr><td>Id</td><td><input type="text" name="id" value="<%=idPerson%>" readonly="readonly" /></td></tr>
                <tr><td>Last Name</td><td><input type="text" name="lastName" value=""/></td></tr>
                <tr><td>First Name</td><td><input type="text" name="firstName" value=""/></td></tr>
                <tr><td>Age</td><td><input type="text" name="age" value=""/></td></tr>
            </table>
            <input type="hidden" name="event" value ="addData" />
            <input type="submit" value="Add data"/>
        </form>
       <form action="ActionController" method="POST" name="description">
	   <table>
	   <tr>
	    	<input type="hidden" name="event" value="returnHome" /> 
			<input type="submit" value="Return Home" name="return" />
		</tr>
		</table>
	</form>
 
    </body>
</html>